#pragma once
#include "loadUtils.h"
/**
 * @brief Struct for storing lockercompartment data
 */
struct LockerCompartmentVars{
	char lockerid[10];
	int compartmentid;
	int lockercode;
	char state[15];
	int placementdate;
	int expirydate;
};

/**
 * @brief Array of LockerCompartmentVars structs, allocated dynamically later on
 */
struct LockerCompartmentVars *lockercompartmentdata;

/**
 * @brief keeps count of how many lockercompartments we have, also used for memory reallocation
 */
int lockercompartmentcount;

/**
 * @brief Load lockercompartment file into memory
 *
 * @param filename
 *
 * @return return code
 */
int loadLockerCompartments(char const *filename);

/**
 * @brief save lockercompartmentdata to file
 *
 * @param filename
 *
 * @return return code
 */
int writeLockerCompartments(char const *filename);

/**
 * @brief add a lockercompartment to the vector, reallocates if needed
 *
 * @param n
 */
void addLockerCompartment(struct LockerCompartmentVars n);

/**
 * @brief removes a lockercompartment by index, find it yourself first ;)
 *
 * @param index
 */
void rmLockerCompartment(int index);

/**
 * @brief read the array of structs
 *
 */
void readLockerCompartments();

/**
 * @brief changes the state of the compartment (ocupado/vacío)
 *
 * @param index
 */
void changeCompartmentState(int index);

/**
 * @brief changes the locker's code, which is used for the pickup
 *
 * @param locker and compartment 
 */
void changeLockerCode(int index);

/**
 * @brief says to the user in which compartment is allocated his product
 *
 */
void pickupCompartmentLocker();

/**
 * @brief delete from compartments file the compartments of a deleted locker
 *
 * @param locker and compartment´s number
 */
void deleteLockerCompartment(char *locker,int numberCompartments);

/**
 * @brief creates new compartments after the creation of a new locker
 *
 * @param locker and number of compartment 
 */
void newCompartment(char *locker, int numberCompartments);

/**
 * @brief assigns the first compartment that is "vacio"
 *
 * @param locker
 */
void assignmentLocker(char *locker);


/**
 * @brief calculates the expiry date
 *
 * @param locker and compartment
 */
void expirydateCompartment(char *locker, int compartment);